/**
 * @Project POL3Cay
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Feb 18, 2011
 * @Createtime 1:33:59 PM
 */

package models.dealer
{
	import events.BaCayEvent;

	import interfaces.IDealer;

	import models.card.BaCayHand;
	import models.card.Deck;

	public class BaCayDealer extends BaseDealer implements IDealer
	{
		public function BaCayDealer()
		{
		}

		public function dealCard(deck:Deck, hands:Vector.<BaCayHand>, loop:int):void
		{
			var currentCardIndex:int = 0;

			for (var i:int = 0; i < loop; i++)
			{
				for each (var hand:BaCayHand in hands)
				{
					if (hand != null)
					{
						hand.receiveCard(deck.cardsSet[currentCardIndex], i + 1);
						currentCardIndex++;
					}
				}
			}

			dispatchEvent(new BaCayEvent(BaCayEvent.DEAL_CARD_DONE));
		}
	}
}